//
//  MessagerDetailViewController.m
//  WheatPlan
//
//  Created by 郑渊文 on 6/24/15.
//  Copyright (c) 2015 IOSTeam. All rights reserved.
//

#import "MessagerDetailViewController.h"

@interface MessagerDetailViewController ()

{
    UIButton *backBtn;
}
@property(nonatomic,copy)NSString *messageDetail;

@end

@implementation MessagerDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString *ID = [user objectForKey:@"ID"];
    NSDictionary *param5 = @{@"userId":ID,@"messageId":_messageId};
 
    [UserDAL getMessageDetailsParams:param5 withBlock:^(NSDictionary *data, NSError *error) {
        if (data) {
            ////NSLog(@"what%@",data);

            _messageDetail =data[@"messageContent"];
        }else
        {
            
        }
    }];
//    self.title = @"消息详情";
    
    // Do any additional setup after loading the view.
}

-(void)viewDidAppear:(BOOL)animated
{
      [self initsubViews];
}
-(void)initsubViews
{
    self.navigationItem.title = @"消息详情";
    [self.navigationController.navigationBar setTranslucent:NO];//设置navigationbar的半透明
    [self.navigationController.navigationBar setBarTintColor:[GetFileModel colorWithHexString:@"#34bd81" alpha:1]];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];

    self.view.backgroundColor = [UIColor clearColor];
    
    
    //自定义左右按钮
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setBackgroundImage:[UIImage imageNamed:@"_0000_返回.png"]
     
                      forState:UIControlStateNormal];
    
    [button addTarget:self action:@selector(back)
     
     forControlEvents:UIControlEventTouchUpInside];
    
    button.frame = CGRectMake(0, 0, 20, 15);
    
    
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
    
    
    
    self.navigationItem.leftBarButtonItem = menuButton;

    
    UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [self.view addSubview:bgView];
    bgView.backgroundColor = [UIColor whiteColor];
    
    UILabel *introduceLable = [[UILabel alloc]initWithFrame:CGRectMake(40, 10, SCREEN_WIDTH-20, 60)];
    introduceLable.numberOfLines = 0;
    introduceLable.textColor = [UIColor blackColor];
//    introduceLable.backgroundColor = [UIColor yellowColor];
    introduceLable.font = [UIFont fontWithName:@"Helvetica" size:13];
    
    NSString *text = _messageDetail;
    ////NSLog(@"hahahha%@",_messageDetail);
    UIFont *font = [UIFont fontWithName:@"Helvetica" size:13.0];
    CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(SCREEN_WIDTH-20, 2000.0f)
                       lineBreakMode:NSLineBreakByWordWrapping];
    CGRect rect = introduceLable.frame;
    rect.size = size;
    [introduceLable setFrame:rect];
    [introduceLable setText:text];
    [bgView addSubview:introduceLable];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)back
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
